<?
require_once("../config/dbconn.php");require_once("../config/usercls.php");require_once("../config/pagecls.php");

$sqlhy="select * from {$db_prefix}users where id='".$_SESSION['sys_userid']."'";
$rshy=$db->get_one($sqlhy);

if($act=='hyzmd'){

	
	$sqlchk="select * from {$db_prefix}applyzmd1 where username='".$_SESSION['sys_username']."' and state=0";
	$rschk=$db->get_one($sqlchk);
	if ($rschk){
		$msg.="您已经申请过了\\n\\n请耐心等待管理员申请";
	}
	if ($msg!=''){
		echo "<script>alert('$msg');history.back();</script>";exit();
	}
	
	//判断是否有足够的报单币
	/*
	if($glo_zmdsqkbdprice==1){
		$glornamebd="glo_zmdregprice_".$zmdrank;
		if($rshy['price']<$$glornamebd){
			$msg.="您没有足够的报单币\\n";
			echo "<script>alert('$msg');history.back();</script>";exit();
		}
	}*/
	//看是否推荐了｛$glo_fwzxnum｝个人了
	/*$sqltj="select count(id) as c from {$db_prefix}users where tjuser='".$_SESSION["sys_username"]."' and state=1";
	$rstj=$db->get_one($sqltj);
	$tjnum=intval($rstj['c']);
	if ($tjnum<$glo_fwzxnum){
		$msg.="必须推荐{$glo_fwzxnum}个人才能申请报单中心\\n\\n";
	}
	*/
	
	if ($msg!=''){
		echo "<script>alert('$msg');history.back();</script>";exit();
	}
	
	//插入申请记录中
	unset($dataArray);
	$dataArray['username']=$_SESSION['sys_username'];
//	$dataArray['zmdname']=trim($zmdname);
	$dataArray['zmdrank1']=$zmdrank1;
//	$dataArray['zmdprovince']=$province;
//	$dataArray['zmdcity']=$city;
//	$dataArray['zmdarea']=$area;
//	$dataArray['zmdaddress']=trim($address);
	$dataArray['addtime']=$curtime;
	$dataArray['state']=0;
	$dataArray['edittime']=0;
	$db->insert("{$db_prefix}applyzmd1",$dataArray);
	
	echo "<script>alert('申请已经提交\\n\\n请等待管理员审核');location.href='user_zmdlst1.php';</script>";exit();
}

if($action=='del'){
	$db->delete("{$db_prefix}applyzmd1","id='$id'");
	echo "<script>location.href='user_zmdlst1.php?pageno={$pageno}';</script>";exit();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="js/user_zmd.js"></script>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	
}
td{
font-size:12px;
}
.red{
	color:#FF0000
}
.hmgc001 {
	font-size: 14px;
	font-weight: bold;
	color: #ffffff;
}
-->
</style>

<link href="images/skin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" height="29" valign="top" ></td>
    <td width="100%" height="29" valign="top" ><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">申请专卖店/Apply to the Special Counter</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" ></td>
  </tr>
  <tr>
    <td height="71" valign="middle" background="images/mail_leftbg1.png">&nbsp;</td>
    <td valign="top"><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top">
		  <table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td height="13" valign="top">&nbsp;</td>
            </tr>
            <tr>
              <td align="center" valign="top"><?
		if ($rshy['isdp1']==1){
		?>
                您已经是专卖店了！
                <?
		}else{
		?>
        <form id="form1" name="form1" method="post" action="?act=hyzmd">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td colspan="3"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
                  <tr>
                    <td class="left_bt2"></td>
                  </tr>
              </table></td>
            </tr>
            <tr>
              <td height="30" colspan="3"><table width="100%" height="180" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td height="30" align="center" class="left_txt">会员/Member</td>
                    <td height="30" class="left_txt"><?=$rshy['username']?></td>
                  </tr>
                  <tr>
                    <td height="30" align="center" class="left_txt">申请级别/Application level</td>
                    <td height="30" class="left_txt"><label>
                      <select name="zmdrank1" id="zmdrank1" value="zmdrank1">
                       <option value ="zmdrank1">专卖店</option>
                      </select>
                      <span class="red">*</span></label></td>
                  </tr>
                 
              </table></td>
            </tr>
            <tr>
              <td height="30" colspan="3" align="center" class="red"><label id="reg_notice" class="red"></label>
                  <br>
                  <?
			  if ($glo_zmdsqkbdprice==1) echo "您的账户报单余额:".$rshy['price']."人民币";
			  ?>
              </td>
            </tr>
            <tr>
              <td width="50%" height="30" align="right"><input type="submit" value="申请/Application" name="B1" /></td>
              <td width="6%" height="30" align="right">&nbsp;</td>
              <td width="44%" height="30">&nbsp;</td>
            </tr>
            <tr>
              <td height="30" colspan="3">&nbsp;</td>
            </tr>
          </table>
        </form>
                <?
		  }
		  ?>
              </td>
            </tr>
          </table>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
                <tr>
                  <td class="left_bt2">&nbsp;&nbsp;&nbsp;&nbsp;</td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td height="30"><table width="100%" height="60" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td height="30" align="center" bgcolor="#f2f2f2" >编号/Number</td>
                  <td align="center" bgcolor="#f2f2f2" >会员/Member</td>
                  <td align="center" bgcolor="#f2f2f2" >专卖店级别/Special Counter level</td>
                  <td align="center" bgcolor="#f2f2f2" >状态/Status</td>
                  <td align="center" bgcolor="#f2f2f2" >申请时间/Application Period</td>
                  <td align="center" bgcolor="#f2f2f2" >审核时间/Audit time</td>
                  <td height="30" align="center" bgcolor="#f2f2f2" >操作/Operating</td>
                  </tr>
  <?
  $query='';
  if ($action=='query'){
  	
  }
  $sql="select count(id) as c  from {$db_prefix}applyzmd1 where username='".$_SESSION['sys_username']."'";
  if ($query!='') $sql.=$query;
  $rs=$db->get_one($sql);
  $page=new pagecls(20,intval($rs['c']));
  $sql="select * from {$db_prefix}applyzmd1 where username='".$_SESSION['sys_username']."'";
  if ($query!='') $sql.=$query;
  $sql.=" order by id desc limit {$page->pastnum},{$page->pagesize}";
  $result=$db->query($sql);
  while($rs=$db->fetch_array($result)){
  ?>
                <tr>
                  <td align="center"><?=$rs['id']?></td>
                  <td align="center"><?=$rs['username']?></td>
                  <td align="center"><?=$zmdrank1ary[$rs['zmdrank1']]?></td>
                  <td align="center" ><? if($rs['state']==0) echo "未处理";elseif($rs['state']==1) echo "已升级";else echo "已拒绝";?></td>
                  <td align="center" ><?=date("Y-m-d H:i:s",$rs['addtime'])?></td>
                  <td align="center" ><? if ($rs['edittime']>0) echo date("Y-m-d H:i:s",$rs['edittime'])?></td>
                  <td height="30" align="center" ><a href="?action=del&id=<?=$rs['id']?>&pageno=<?=$page->pageno?>">删除</a></td>
                  </tr>
	<?
  }
  $db->free_result($result);
  ?>
              </table></td>
            </tr>
            
            <tr>
              <td height="30">&nbsp;</td>
            </tr>
            <tr>
              <td height="30" align="right">每页/Per<?=$page->pagesize?>条/Article 第/First<?=$page->pageno?>/<?=$page->pagenum?>页/Page 共/Common<?=$page->recnum?>条/Article <a href='?<?=$page->url?>1'><img src="image1/first.gif" border="0"></a>   <a href='?<?=$page->url.($page->pageno-1)?>'><img src="image1/back.gif" border="0"></a>  <a href='?<?=$page->url.($page->pageno+1)?>'><img src="image1/next.gif" border="0"></a>   <a href='?<?=$page->url.$page->pagenum?>'><img src="image1/last.gif" border="0"></a></td>
              </tr>
            <tr>
              <td height="30">&nbsp;</td>
            </tr>
          </table></td>
      </tr>
    </table></td>
    <td background="images/mail_rightbg.png">&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" ></td>
      <td height="17" valign="top" ></td>
    <td></td>
  </tr>
</table>

</body>
</html>
